package com.yueya.basic.main;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.yueya.basic.dept.model.Dept;
import com.yueya.basic.menu.Menu;
import com.yueya.common.action.BaseController;

/**
 * MainController
 */

public class MainController extends BaseController {

	public void index() {
		Map<String, Object> map = new HashMap<String, Object>();
		Record user = getUserWithCookie();
		if (user != null) {
			String userid = user.getStr("user_id");
			map.put("userid", userid);
			List<Menu> menus1 = Menu.service.getMenuOneList(map);
			this.setAttr("menus1", menus1);
			List<Menu> menus2 = Menu.service.getMenuTwoList(map);
			this.setAttr("menus2", menus2);

			this.setAttr("user", user);

		}

		render("/WEB-INF/views/basic/main/index.jsp");
	}

	public void home() {
		Record user = getUserWithCookie();
		this.setAttr("user", user);
		if (user != null) {
			String sql = "select * from t_dept_user where user_id = ?";
			Record r = Db.findFirst(sql, user.getStr("user_id"));
			if (r != null) {
				String deptId = r.getStr("dept_id");
				this.setAttr("dept", Dept.dao.findById(deptId));
			}

		}
		render("/WEB-INF/views/basic/main/home.jsp");
	}
	
	
	public void menu() {
		render("/WEB-INF/views/basic/main/menu.jsp");
	}
	

	public void set() {
		render("/WEB-INF/views/basic/main/personal_set.jsp");
	}

	public void chart1() {
		render("/WEB-INF/views/basic/main/portlet_chart1.jsp");
	}
	public void chart2() {
		render("/WEB-INF/views/basic/main/portlet_chart2.jsp");
	}
	public void chart3() {
		render("/WEB-INF/views/basic/main/portlet_chart3.jsp");
	}
	public void chart4() {
		render("/WEB-INF/views/basic/main/portlet_chart4.jsp");
	}
	public void chart5() {
		render("/WEB-INF/views/basic/main/portlet_chart5.jsp");
	}
	public void chart6() {
		render("/WEB-INF/views/basic/main/portlet_chart6.jsp");
	}

	public void tzgg() {
		render("/WEB-INF/views/basic/main/tzgg_home.jsp");
	}

	public void onlineUser() {

		render("/WEB-INF/views/basic/main/onlineuser_home.jsp");
	}

}
